3 * MediaWiki Widgets – NamespaceInputWidget class.
5 * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt
6 * @license The MIT License (MIT); see LICENSE.txt
8 namespace MediaWiki\Widget
;
11 * Namespace input widget. Displays a dropdown box with the choice of available namespaces.
13 class NamespaceInputWidget
extends \OOUI\DropdownInputWidget
{
15 protected $includeAllValue = null;
18 * @param array $config Configuration options
19 * @param string $config['includeAllValue'] If specified, add a "all namespaces" option to the
20 * namespace dropdown, and use this as the input value for it
22 public function __construct( array $config = array() ) {
23 // Configuration initialization
24 $config['options'] = $this->getNamespaceDropdownOptions( $config );
27 parent
::__construct( $config );
30 $this->includeAllValue
= isset( $config['includeAllValue'] ) ?
$config['includeAllValue'] : null;
33 $this->addClasses( array( 'mw-widget-namespaceInputWidget' ) );
36 protected function getNamespaceDropdownOptions( array $config ) {
37 $namespaceOptionsParams = isset( $config['includeAllValue'] ) ?
38 array( 'all' => $config['includeAllValue'] ) : array();
39 $namespaceOptions = \Html
::namespaceSelectorOptions( $namespaceOptionsParams );
42 foreach ( $namespaceOptions as $id => $name ) {
44 'data' => (string)$id,
52 protected function getJavaScriptClassName() {
53 return 'mw.widgets.NamespaceInputWidget';
56 public function getConfig( &$config ) {
57 $config['includeAllValue'] = $this->includeAllValue
;
58 // Skip DropdownInputWidget's getConfig(), we don't need 'options' config
59 return \OOUI\InputWidget
::getConfig( $config );